package com.test.applicationexitreasontest;

import android.app.ApplicationExitInfo;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

public class MyRecyclerAdapter extends RecyclerView.Adapter<MyRecyclerAdapter.MyHolder> {
    private List<ApplicationExitInfo> list;
    private Context context;

    public MyRecyclerAdapter(List<ApplicationExitInfo> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @NonNull
    @Override
    public MyHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View itemView = LayoutInflater.from(context).inflate(R.layout.adapter_text,parent,false);
        return new MyHolder(itemView);
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    @Override
    public void onBindViewHolder(@NonNull MyHolder holder, int position) {
        ApplicationExitInfo applicationExitInfo = list.get(position);
        holder.textView.setText(applicationExitInfo.toString());
    }

    public class MyHolder extends RecyclerView.ViewHolder{

        private TextView textView;

        public MyHolder(@NonNull View itemView) {
            super(itemView);
            textView = itemView.findViewById(R.id.textView);
        }
    }
}
